<?php 

class _F_EXTENSION_DATA_QUERY_ extends _F_OBJECT_ {
	
	public $db;
	public $query;
	public $stmnt;
	
	public function __construct($db,$query) {
		$this->db = $db;
		$this->query = $query;
		$this->stmnt = $db->connection->prepare($query);
		if ($this->stmnt === false) {
			_F_EXTENSION_DATA_::_f_error_info_($db->connection,$query);
		}
	}
	
	public function param($name,$value) {
		$this->stmnt->bindValue($name,$value);
		return $this;
	}
	
	public function params($params) {
		foreach ($params as $name => $value) 
			$this->stmnt->bindValue($name,$value);
		return $this;
	}
	
	public function exec($params = array()) {
		if (func_num_args())
			$this->params($params);
		if ($this->stmnt->execute()) {
			return $this->stmnt->rowCount();
		} else {
			_F_EXTENSION_DATA_::_f_error_info_($this->db->connection,
				$this->query,$this->stmnt);
			return false;
		}
	}

}

